home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / haziran / 19 / setup.exe / data.z / isapnp_diag_lib.pas < prev    next >
Pascal/Delphi Source File  |  2001-04-11  |  2KB  |  98 lines

  1. {
  2.  ----------------------------------------------------------------
  3.  File - ISAPNP_DIAG_LIB.PAS
  4.  
  5.  Utility functions for printing card information,
  6.  detecting PCI cards, and accessing PCI configuration
  7.  registers.
  8.  
  9.  ----------------------------------------------------------------
  10. }
  11.  
  12. unit ISAPnP_diag_lib;
  13.  
  14. interface
  15.  
  16. uses
  17.     Windows,
  18.     SysUtils,
  19.     WinDrvr,
  20.     Print_Struct;
  21.  
  22. function ISAPNP_Get_WD_handle(phWD : PHANDLE) : BOOLEAN;
  23. procedure ISAPNP_Print_all_cards_info;
  24.  
  25.  
  26. implementation
  27.  
  28. function ISAPNP_Get_WD_handle(phWD : PHANDLE) : BOOLEAN;
  29. var
  30.     ver : SWD_VERSION;
  31.  
  32. begin
  33.     phWD^ := INVALID_HANDLE_VALUE;
  34.     phWD^ := WD_Open();
  35.  
  36.     { Check whether handle is valid and version OK }
  37.     if phWD^ = INVALID_HANDLE_VALUE
  38.     then
  39.     begin
  40.         Writeln('Cannot open WinDriver device');
  41.         ISAPNP_Get_WD_handle := False;
  42.     Exit;
  43.     end;
  44.  
  45.     FillChar(ver, SizeOf(ver), 0);
  46.     WD_Version(phWD^,ver);
  47.     if ver.dwVer<WD_VER
  48.     then
  49.     begin
  50.         Writeln('Error - incorrect WinDriver version');
  51.         WD_Close (phWD^);
  52.         phWD^ := INVALID_HANDLE_VALUE;
  53.         ISAPNP_Get_WD_handle := False;
  54.     end
  55.    else
  56.        ISAPNP_Get_WD_handle := True;
  57. end;
  58.  
  59. procedure ISAPNP_Print_all_cards_info;
  60. var
  61.     hWD : HANDLE;
  62.     scanCards : WD_ISAPNP_SCAN_CARDS;
  63.     cardInfo : WD_ISAPNP_CARD_INFO;
  64.     i, j : DWORD;
  65.  
  66. begin
  67.     if not ISAPNP_Get_WD_handle (@hWD)
  68.     then
  69.         Exit;
  70.  
  71.     Writeln('ISA PnP bus scan:');
  72.     Writeln('');
  73.     FillChar(scanCards, SizeOf(scanCards), 0);
  74.     WD_IsapnpScanCards (hWD, scanCards);
  75.     for i:=1 to scanCards.dwCards do
  76.     begin
  77.         Writeln('Card ', i-1, ': ', scanCards.Card[i-1].cIdent);
  78.         for j:=1 to scanCards.Card[i-1].dcLogicalDevices do
  79.         begin
  80.             FillChar(cardInfo, SizeOf(cardInfo), 0);
  81.             cardInfo.cardId := scanCards.Card[i-1].cardId;
  82.             cardInfo.dwLogicalDevice := j-1;
  83.             WD_IsapnpGetCardInfo(hWD, cardInfo);
  84.             if StrLen(cardInfo.cIdent) <> 0 then
  85.                Write('Device ', j-1, ': ', cardInfo.cIdent, ', ');
  86.             Write('Vendor ID: ', scanCards.Card[i-1].cardId.cVendor, ', ');
  87.             Write('Serial number: ', IntToHex(scanCards.Card[i-1].cardId.dwSerial, 8));
  88.         Writeln('');
  89.             WD_CARD_print(@cardInfo.Card, '   ');
  90.             Writeln('');
  91.         end;
  92.     end;
  93.     WD_Close (hWD);
  94. end;
  95.  
  96. end.
  97.  
  98.